<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    
    <head>
        <meta charset="utf-8">
        <title>
            添加关于我们
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form">

                <div class="layui-form-item">
                    <label for="bigTitle" class="layui-form-label">
                        大标题
                    </label>
                    <div class="layui-input-inline">
                        <input type="text"  id="bigTitle" name="bigTitle"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="title1" class="layui-form-label">
                        小标题
                    </label>
                    <div class="layui-input-inline">
                        <input type="text"  id="title1" name="title1"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>



                <div class="layui-form-item">
                    <label for="wztitle" class="layui-form-label">
                        <span class="x-red">*</span>关于类型
                    </label>
                    <div class="layui-input-inline">
                        <div class="layui-input-block">
                            <input type="radio" name="aboutStyle" value="0" title="品牌故事">
                            <input type="radio" name="aboutStyle" value="1" title="企业文化">
                            <input type="radio" name="aboutStyle" value="2" title="合作伙伴">
                            <input type="radio" name="aboutStyle" value="3" title="联系我们">
                        </div>
                    </div>
                </div>

                <div class="text" id="div2">

                </div>

                <br><br>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="">
                        保存
                    </button>
                </div>
            </form>

            <div class="x-body" id="div3">

            </div>



        </div>
        <script src="/js/jquery-2.2.4.min.js" charset="utf-8">
        </script>
        <script src="/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="/js/x-layui.js" charset="utf-8">
        </script>
        <script src="/js/vue.js" charset="utf-8">
        </script>
        <script type="text/javascript" src="/js/wangEditor.js"></script>
        <script>

            var E = window.wangEditor
            var editor = new E('#div2');
            editor.customConfig.pasteIgnoreImg = false;
            editor.customConfig.uploadImgShowBase64 = true;

            editor.customConfig.uploadImgServer = '/upload';
            editor.customConfig.uploadFileName = 'file';

            editor.customConfig.menus = [
                'bold',  // 粗体
                'fontSize',  // 字号
                'italic',  // 斜体
                'underline',  // 下划线
                'strikeThrough',  // 删除线
                'foreColor',  // 文字颜色
                'backColor',  // 背景颜色
                'code',  // 插入代码
                'link',  // 插入链接
                'justify',  // 对齐方式
                'quote',  // 引用
                'emoticon',  // 表情
                'image',  // 插入图片
                'table',  // 表格
                'video',  // 插入视频
                'undo'  // 撤销

            ]


            editor.customConfig.onfocus = function () {

            }

            editor.customConfig.onblur = function (html) {

            }

            editor.create();


            var imageFilename = '';

            layui.use(['form','layer', 'upload'], function(){
                $ = layui.jquery;
              var form = layui.form();
              var layer = layui.layer;

                layui.upload({
                    url: '/bo/homePicture/upload.html', //上传接口
                    success: function(res){ //上传成功后的回调
                        imageFilename = res.data.filename;
                        $('#productImage').html('<img src="'+ res.data.imageUrl +'" width="100px" height="40px">');
                    }
                });

                var featurePro = [];
              //监听提交
              form.on('submit(add)', function(data){

                  var context = editor.txt.html();

                //发异步，把数据提交给服务器
                  $.ajax({
                      url: '/bo/addAbout',
                      type: 'POST', //GET
                      async: true,    //或false,是否异步
                      data: {
                          bigTitle : $('#bigTitle').val(),
                          title1 : $('#title1').val(),
                          wzcontext : context,
                          aboutStyle : $("input[name='aboutStyle']:checked").val()
                      },
                      timeout: 10000,    //超时时间
                      dataType: 'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                      success: function (ajaxData, textStatus, jqXHR) {
                          if (1000 != ajaxData.code) {
                              layer.alert(ajaxData.message, {icon: 5},function (index) {
                                  layer.close(index);
                              });

                              return;
                          }

                          layer.alert('保存成功', {icon: 6},function (index) {
                              layer.close(index);
                              location.reload();
                          });

                      }
                  });

                return false;
              });
            });

        </script>
        <script>

        </script>
    </body>

</html>